# Define node js version
FROM harbor.wistron.com/base_image/node:16

# USER root


# Move all file to /app directory
ADD . /app/

# Set working directory to /app
WORKDIR /app

RUN apt-get update
RUN yes |  apt-get install poppler-utils

ENV http_proxy=
ENV https_proxy=

# Install depandancy component
RUN npm install


RUN chmod +x ./public/*
RUN chmod +rx ./ghostscript-9.53.3/*
RUN chmod +rx ./libpng-1.6.31/*
RUN chmod +rx ./jpeg-9b/*
RUN chmod +rx ./GraphicsMagick-1.3.35/*
# git update-index --chmod +x ./ghostscript-9.53.3-linux-x86_64


# RUN ./GraphicsMagick-1.3.35/configure
# RUN make
# RUN make install
# # --prefix=/usr/local/bin
# RUN ./jpeg-9b/configure 
# RUN make
# RUN make install
# # --prefix=/usr/local/bin
# git update-index --chmod +x .\ghostscript-9.53.3-linux-x86_64\gs-9533-linux-x86_64

# RUN apt-get install poppler-utils

WORKDIR ./ghostscript-9.53.3
RUN ./configure
RUN make
RUN make install

WORKDIR /app/libpng-1.6.31
RUN ./configure
RUN make
RUN make install

WORKDIR /app/jpeg-9b
RUN ./configure
RUN make
RUN make install

WORKDIR /app/GraphicsMagick-1.3.35
RUN ./configure
RUN make
RUN make install




WORKDIR /app


# Set external port
EXPOSE 8977
EXPOSE 8978

# CMD: node .
CMD ["node", "app.js"]
